<template>
  <div class="full-box shadow-box padding-box">
    <OperateCommon :showSearch="true" :showAdd="false" @search="initData">
      <template #condition>
        <div class="condition-item"></div>
      </template>
    </OperateCommon>
    <div class="table-wrapper">
      <!-- <BaseTable
        :columns="columns"
        :showSort="true"
        :tableData="tableData"
        :pages="{
          show: true,
          count: count,
        }"
        :operate="{
          show: false,
          width: 200,
        }"
        @pagination="pageChange"
      >
        <template #operate="{ current }">
          <el-button type="primary" size="mini" @click="linkWhere(current.row)"
            >详情</el-button
          > 
        </template>
      </BaseTable> -->
      <el-table
        height="100%"
        :header-cell-style="{
          background: '#e6e8ec',
          color: '#000',
          height: '60px',
        }"
        :data="tableData"
        stripe
      >
        <el-table-column
          v-for="(col, index) in columns"
          :prop="col.prop"
          :key="'bs_' + index"
          :label="col.label"
          :width="col.width"
          :min-width="col.minWidth || '0'"
          :align="col.align || 'center'"
          :fixed="col.fixed"
        >
          <template slot-scope="scope">
            <span v-if="col.prop == 'description'">
              <el-popover trigger="hover" placement="top">
                <div>
                  {{ scope.row[col.prop] }}
                </div>
                <div slot="reference" class="name-wrapper">
                  <el-tag type="danger" size="mini">预警规则</el-tag>
                </div>
              </el-popover>
            </span>
            <span v-else-if="col.prop == 'warning_level'">
              <i
                class="iconfont icon-yujing1"
                :style="{ color: scope.row[col.prop] == 1 ? 'yellow' : 'red' }"
              ></i>
            </span>
            <span v-else>
              {{ scope.row[col.prop] }}
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import BaseTable from "@/components/Common/BaseTable.vue";
import OperateCommon from "@/components/Common/OperateCommon.vue";
import LinkTo from "@/mixins/LinkTo";
import { getOneCaseThreeCheckList } from "@/api/RedAlert/Index";
import commonList from "@/mixins/commonList";
export default {
  mixins: [LinkTo, commonList],
  components: { BaseTable, OperateCommon },
  data() {
    return {
      columns: columns,
      tableData: [],
      count: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
      },
    };
  },
  methods: {
    initData() {
      getOneCaseThreeCheckList(this.queryParams).then((res) => {
        if (res.code == 0) {
          this.tableData = res.data;
          this.count = res.num;
        }
      });
    },
    pageChange(val) {
      this.queryParams.pageNum = val.pageNum;
      this.queryParams.pageSize = val.pageSize;
      this.initData();
    },
    deleteConfirm(id) {
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.deleteItem(id);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    deleteItem(id) {
      deleteDept({ id: id }).then((res) => {
        if (res.code == 0) {
          this.$message.success("删除成功");
          this.initData();
        }
      });
    },
    linkWhere(item) {
    },
  },
  created() {
    this.initData();
  },
};

const columns = [
  {
    prop: "project_name",
    label: "项目名称",
    width: "",
    minWidth: "300",
    align: "",
  },
  {
    prop: "dept_name",
    label: "预警单位",
    width: "",
    minWidth: "200",
    align: "",
  },
  {
    prop: "warning_level",
    label: "预警级别",
    width: "",
    minWidth: "100",
    align: "",
  },
  {
    prop: "description",
    label: "预警监控点",
    width: "100",
    minWidth: "",
    align: "",
  },
  {
    prop: "trigger_time",
    label: "预警发生时间",
    width: "150",
    minWidth: "",
    align: "",
  },
  {
    prop: "undertake_dept_name",
    label: "承办单位",
    width: "200",
    minWidth: "",
    align: "",
  },
  {
    prop: "solve_date",
    label: "办理时间",
    width: "150",
    minWidth: "",
    align: "",
  },
  {
    prop: "responsible_dept_name",
    label: "主体责任",
    width: "80",
    minWidth: "",
    align: "",
  },
  {
    prop: "supervise_dept_name",
    label: "党建责任",
    width: "80",
    minWidth: "",
    align: "",
  },
  {
    prop: "user_name",
    label: "当事人责任",
    width: "80",
    minWidth: "",
    align: "",
  },
];
</script>

<style lang="scss" scoped>
</style>